package com.sxpcwlkj.system.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.sxpcwlkj.common.code.controller.BaseController;
import com.sxpcwlkj.common.utils.AjaxResult;
import com.sxpcwlkj.framework.entity.page.PageQuery;
import com.sxpcwlkj.framework.entity.page.TableDataInfo;
import com.sxpcwlkj.system.entity.bo.SysConfigBo;
import com.sxpcwlkj.system.entity.vo.SysConfigVo;
import com.sxpcwlkj.system.service.SysConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
* 配置表
*
* @author 西决 942879858@qq.com
* @since 1.0.0 2024-05-23
*/
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("system/sysConfig")
public class SysConfigController extends BaseController{
    private final SysConfigService baseService;


    @SaCheckPermission("system:sysConfig:list")
    @PostMapping("/list")
    public TableDataInfo<SysConfigVo> listPage(@Validated @RequestBody(required = false) SysConfigBo bo, PageQuery pageQuery){
         return baseService.selectListVoPage(bo, pageQuery);
    }

    @SaCheckPermission("system:sysConfig:query")
    @GetMapping("/{id}")
    public AjaxResult<SysConfigVo> queryById(@PathVariable String id) {
        return success(baseService.selectVoById(id));
    }

    @SaCheckPermission("system:sysConfig:edit")
    @PutMapping
    public AjaxResult<Boolean> edit(@Validated @RequestBody(required = false) SysConfigBo bo) {
        return success(baseService.updateById(bo));
    }

    @SaCheckPermission("system:sysConfig:insert")
    @PostMapping
    public AjaxResult<Boolean> insert(@Validated @RequestBody(required = false) SysConfigBo bo) {
        return success(baseService.insert(bo));
    }

    @SaCheckPermission("system:sysConfig:delete")
    @DeleteMapping("/{id}")
    public AjaxResult<Boolean> delete(@PathVariable String id) {
        return success(baseService.deleteById(id));
    }

}
